package com.tianji.learning.controller.admin;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.query.QuestionAdminPageQuery;
import com.tianji.learning.domain.vo.QuestionAdminVO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 互动提问的问题表 前端控制器
 * </p>
 *
 * @author waker
 * @since 2025-10-25
 */
@Api(tags = "管理端-问题相关接口")
@RestController
@RequestMapping("/admin/questions")
@RequiredArgsConstructor
public class InteractionAdminQuestionController {

    private final IInteractionQuestionService questionService;

    /**
     * 6. 管理端-分页查询互动问题列表
     * @param query
     * @return
     */
    @GetMapping("/page")
    @ApiOperation("分页查询互动问题列表")
    public PageDTO<QuestionAdminVO> pageQuery(QuestionAdminPageQuery query){
        return questionService.adminPageQuery(query);
    }


    /**
     * 7. 管理端-显示或隐藏问题
     * @param id
     * @param hidden
     */
    @ApiOperation("显示或隐藏问题")
    @PutMapping("/{id}/hidden/{hidden}")
    public void displayOrHideQuestion(@PathVariable("id") Long id, @PathVariable("hidden") boolean hidden){
        questionService.displayOrHideQuestion(id, hidden);
    }

    /**
     * 8. 管理端-根据id查询问题详情
     * @param id
     * @return
     */
    @ApiOperation("根据id查询问题详情")
    @GetMapping("/{id}")
    public QuestionAdminVO queryQuestionById(@PathVariable("id") Long id){
        return questionService.adminQueryQuestionById(id);
    }

}
